package opeartion;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class ReturnOperation implements IOPeration{
    @Override
    public void work(BookList bookList) {
        System.out.println("归还图书！");
        System.out.println("请输入归还图书的名字：");
        Scanner in=new Scanner(System.in);
        String name=in.nextLine();
        int size= bookList.getUsedSize();
        for (int i = 0; i < size; i++) {
            Book book= bookList.getBooks(i);
            if(name.equals(book.getName())){
                book.setBoroowed(false);
                System.out.println("归还成功！");
                return;
            }
        }
        System.out.println("没有借阅过这本书或者根本没有这本书！");
    }
}
